package com.ruoyi.bath.artiificer.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bath.artiificer.domain.Artificer;
import com.ruoyi.bath.artiificer.service.IArtificerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 技师信息Controller
 * 
 * @author ruoyi
 * @date 2021-08-06
 */
@RestController
@RequestMapping("/bath/artificer")
public class ArtificerController extends BaseController
{
    @Autowired
    private IArtificerService artificerService;

    /**
     * 查询技师信息列表
     */
   // @PreAuthorize("@ss.hasPermi('bath:artificer:list')")
    @GetMapping("/list")
    public TableDataInfo list(Artificer artificer)
    {
        startPage();
        List<Artificer> list = artificerService.selectArtificerList(artificer);
        return getDataTable(list);
    }

    /**
     * 导出技师信息列表
     */
    @PreAuthorize("@ss.hasPermi('bath:artificer:export')")
    @Log(title = "技师信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Artificer artificer)
    {
        List<Artificer> list = artificerService.selectArtificerList(artificer);
        ExcelUtil<Artificer> util = new ExcelUtil<Artificer>(Artificer.class);
        return util.exportExcel(list, "技师信息数据");
    }

    /**
     * 获取技师信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bath:artificer:query')")
    @GetMapping(value = "/{artificerId}")
    public AjaxResult getInfo(@PathVariable("artificerId") Integer artificerId)
    {
        return AjaxResult.success(artificerService.selectArtificerByArtificerId(artificerId));
    }

    /**
     * 新增技师信息
     */
    @PreAuthorize("@ss.hasPermi('bath:artificer:add')")
    @Log(title = "技师信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Artificer artificer)
    {
        return toAjax(artificerService.insertArtificer(artificer));
    }

    /**
     * 修改技师信息
     */
    @PreAuthorize("@ss.hasPermi('bath:artificer:edit')")
    @Log(title = "技师信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Artificer artificer)
    {
        return toAjax(artificerService.updateArtificer(artificer));
    }

    /**
     * 删除技师信息
     */
    @PreAuthorize("@ss.hasPermi('bath:artificer:remove')")
    @Log(title = "技师信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{artificerIds}")
    public AjaxResult remove(@PathVariable Integer[] artificerIds)
    {
        return toAjax(artificerService.deleteArtificerByArtificerIds(artificerIds));
    }

}
